package com.shop.cereshop.business.dl.logic.demo.wechatpay;

import com.shop.cereshop.business.dl.logic.demo.wechatpay.utils.WechatpayUtil;
import com.shop.cereshop.business.dl.logic.demo.wechatpay.utils.entity.ResultEntity;
import com.shop.cereshop.business.dl.logic.demo.wechatpay.utils.entity.TransfersDto;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@RestController
public class TestApp {

    @Value("${weixin.certurl}")
    private String CERTPATH;
    private static final Log LOG = LogFactory.getLog(TestApp.class);
//    @RequestMapping("/to/to/shuai")
    public void ttt() {

        String appkey = "jxjxjjxjjjxjjcjxjjcmjxjjcm123123";// 微信商户秘钥, 根据实际情况填写
//        String certPath = "C:\\Users\\tww\\Desktop\\yml线上配置\\证书\\线上文旅证书\\apiclient_cert.p12";// 微信商户证书路径, 根据实际情况填写
        String certPath = CERTPATH;

        TransfersDto model = new TransfersDto();// 微信接口请求参数, 根据实际情况填写
        model.setMch_appid("wx0e060e3fdcd9a7c9"); // 申请商户号的appid或商户号绑定的appid
        model.setMchid("1576848071"); // 商户号
        model.setMch_name("小黄狗商户号"); // 商户名称
        model.setOpenid("on5gq6PcV-1oH1iDEn8fImjzTknk"); // 商户appid下，某用户的openid
        model.setAmount(1); // 企业付款金额，这里单位为元
        model.setDesc("测试企业付款到零钱");

        // 微信官方API文档 https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
        ResultEntity iResult = WechatpayUtil.doTransfers(appkey, certPath, model);
        LOG.info(iResult);
    }
}
